<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <style>
        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
            height: 35px;
            vertical-align: text-top;
            padding-top: 2px;
        }

        .error {
            color: red;
        }

        .formsHead {
            font-size: 16px;
            font-weight: bold;
            color: blue;
        }
    </style>
</head>
<body class="no-skin">

<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <div class="pull-left">
                            <button class="btn btn-sm btn-info" id="query">条件搜索</button>
                            <%-- <shiro:hasPermission name="modules:sys:huashu:query"></shiro:hasPermission> --%>
                            <button class="btn btn-sm btn-success" id="create">新建任务</button>
                            <button class="btn btn-sm btn-default" id="edits">任务修改</button>
                            <button class="btn btn-sm btn-info" id="createLog">任务催办</button>
                            <button class="btn btn-sm btn-danger" id="feedback">反馈领导</button>
                            <button class="btn btn-sm btn-info" id="restartjob">重新督查</button>
                            <button class="btn btn-sm btn-success" id="createRecord">添加完成情况</button>
                            <button class="btn btn-sm btn-danger" id="delete" style="display: none;">删除</button>

                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
    <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
</div><!-- /.main-container -->
</div>

<%--公用js--%>
<script src="<s:url value="/assets/web/js/commo.js"></s:url>"></script>
<%--多选js--%>
<%--<script src="<s:url value="/assets/web/js/multiSelect/js/fselect.js"></s:url>"></script>--%>
<%--<script src="<s:url value="/assets/web/common/bootstrapvalidator/dist/js/bootstrapValidator.js"></s:url>"></script>--%>

<!-- footer -->
<%@ include file="/WEB-INF/views/include/footer.jsp" %>

<script type="text/javascript">
    //基本路径
    var baseUrl = "<s:url value="/jobmanages"></s:url>/"
    //jqgrid的表格高度
    var height = 320;
    //jqgrid表格行头的中文
    var colNames = [
        '任务单号', '任务名称', '任务内容', '计划开始时间', '计划结束时间',
        '开始时间', '结束时间', /*'任务阶段',*/ /*'是否重新生成任务',*/ '督查轮数',
        '指标编码', '指标名称', '指标时间', '责任单位', '责任单位得分',
        '责任人', '责任人手机号', /*'督查组编码',*/ '督查组名称', '督查组得分',
        '督查组成员', '督查组手机号', '任务状态', '任务最终结果', '责任单位结果',
        '督查组结果', '是否反馈攻坚', '任务类型','任务时间', '响应时间'
    ];
    var colModel = [
        {name: 'sysId', index: 'sysId', width: 164, editable: true, key: true},
        {name: 'taskName', index: 'taskName', width: 160, editable: true},
        {name: 'taskContent', index: 'taskContent', width: 160, editable: true},
        {name: 'planStartDate', index: 'planStartDate', width: 95, editable: true},
        {name: 'planEndDate', index: 'planEndDate', width: 95, editable: true},
        {name: 'startDate', index: 'startDate', width: 75, editable: true},
        {name: 'endDate', index: 'endDate', width: 75, editable: true, formatter: endDateFmatter},
        // {name: 'taskStage', index: 'taskStage', width: 95, editable: true},
        // {name: 'isRebuild', index: 'isRebuild', width: 95, editable: true},
        {name: 'taskTimes', index: 'taskTimes', width: 64, editable: true, formatter: taskTimesFmatter,},
        {name: 'industryId', index: 'industryId', width: 64, editable: true},
        {name: 'industryName', index: 'industryName', width: 140, editable: true},
        {name: 'industryDate', index: 'industryDate', width: 75, editable: true},
        {name: 'resDept', index: 'resDept', width: 100, editable: true},
        {name: 'respScore', index: 'respScore', width: 100, editable: true},
        {name: 'resUser', index: 'resUser', width: 100, editable: true},
        {name: 'resPhone', index: 'resPhone', width: 100, editable: true},
        // {name: 'groupCode', index: 'groupCode', width: 100, editable: true},
        {name: 'groupName', index: 'groupName', width: 100, editable: true},
        {name: 'supervisionScore', index: 'supervisionScore', width: 100, editable: true},
        {name: 'inspectors', index: 'inspectors', width: 100, editable: true},
        {name: 'phones', index: 'phones', width: 100, editable: true},
        {name: 'aaa001', index: 'aaa001', width: 75, editable: true, formatter: aa10Fmatter, cellattr: addCellAttr},
        {name: 'taskResult', index: 'taskResult', width: 95, editable: true, formatter: resultFmatter},
        {name: 'respResult', index: 'respResult', width: 95, editable: true, formatter: resultFmatter},
        {name: 'supervisionResult', index: 'supervisionResult', width: 88, editable: true, formatter: resultFmatter},
        {name: 'isFeedback', index: 'isFeedback', width: 95, editable: true, formatter: isFeedbackFmatter},
        {name: 'taskType', index: 'taskType', width: 95, editable: true, formatter: taskTypeFmatter},
        {name: 'taskDate', index: 'taskDate', width: 75, editable: true},
        {name: 'responseTime', index: 'responseTime', width: 75, editable: true}
    ];

    //jqgrid的具体执行方法
    jqgrid({
        shrinkToFit: false,
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager"
    });

    function aa10Fmatter(cellvalue, options, rowObject) {
        if (cellvalue == "1") {
            return "有效任务";
        } else if (cellvalue == "0") {
            return "失效任务";
        } else {
            return "——";
        }
    }
    function addCellAttr(rowId, val, rawObject, cm, rdata) {
        if (rawObject.aaa001 == "0") {
            return "style='color:red'";
        }
    }
    function resultFmatter(cellvalue, options, rowObject) {
        if (cellvalue == "1") {
            return "已完成";
        } else if (cellvalue == "0") {
            return "未完成";
        }
    }

    function endDateFmatter(cellvalue, options, rowObject) {
        if (cellvalue == "" || cellvalue == null) {
            return "暂未完成";
        } else {
            return cellvalue;
        }
    }

    function isFeedbackFmatter(cellvalue, options, rowObject) {
        if (cellvalue == "1") {
            return "已反馈";
        } else if (cellvalue == "0") {
            return "未反馈";
        }
    }

    function taskTimesFmatter(cellvalue) {
        if (cellvalue != null) {
            return "第" + cellvalue + "轮";
        } else {
            return "——";
        }
    }

    //0自动生成 1手动生成 2问题转批生成
    function taskTypeFmatter(cellvalue, options, rowObject) {
        if (cellvalue == "0") {
            return "自动生成";
        } else if (cellvalue == "1") {
            return "手动生成";
        } else if (cellvalue == "2") {
            return "问题转批";
        } else {
            return "——";
        }
    }

    //加载查询对话框
    $("#queryDialog").load(getUrl("filter"));

    //重置表单
    function reset() {
        resetForm("#formDialog form");
    }

    var exportData = '';
    //显示查询对话框
    var queryDialog = $("#queryDialog");

    /* ---条件搜索 */
    $("#query").click(function () {
        showDialog({
            dialogTitle: '条件搜索',
            dialogBody: queryDialog,
            dialogFoot: "<button type='button' class='btn btn-primary' onclick='query()'>查询</button>" +
                "<button type='button' class='btn btn-pink' onclick='reset()'>重置</button>" +
                "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
        });
    });

    //具体查询方法
    function query() {
        exportData = $('#formDialog form').serialize();
        seachJqgird("#gridTable", "#formDialog form");
        $("#formDialog").modal('hide');
    }

    /* ---任务修改 */
    $("#edits").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "任务详情",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()" id="submit" >修改</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    })

    function edit() {
        console.log("任务修改");
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("edit"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
        //倒计时
        var btn = document.getElementById("submit");
        btn.disabled = true;
        countdown(5);
    }


    /* 手动新建任务按钮 */
    $("#create").click(function () {
        loadDialog({
            dialogTitle: '新建任务',
            dialogUrl: getUrl("create"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">确认</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    /* 催办操作按钮 */
    $("#createLog").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "任务催办",
            dialogUrl: getUrl("createTaskLog"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="cuiBanEdit()"  >确定</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });

    /**
     * ---------------------催办记录提交---------------
     * */
    //执行更新操作
    function cuiBanEdit() {
        console.log("催办记录")
        executeSaveOrUpdate({
            formId: "#formDialogBody form",
            dialogId: "#formDialog",
            url: getUrl("createTaskLog"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
    }

    /**
     * 反馈领导
     */
    $("#feedback").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "反馈领导",
            dialogUrl: getUrl("feedback"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="feedbackLeader()"  >确定</button>' +
                '<!--<button type="button" class="btn btn-pink" onclick="reset()">重置</button>-->' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });


    /**重新督查
     */
    $("#restartjob").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "重新督查",
            dialogUrl: getUrl("rebuildjob"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="Restartedit()"  >确定</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });

    /**添加完成情况
     */
    $("#createRecord").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "添加完成情况",
            dialogUrl: getUrl("createRespRecord"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="recordEdit()" id="" >确定</button>' +
                '<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' +
                '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });


    /**
     * --------------完成情况记录提交事件 recordEdit ----------
     */
    function recordEdit() {
        console.log("催办记录")
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("createRespRecord"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
    }

    /**
     *
     * 反馈领导
     */
    function feedbackLeader() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("feedback"),
            tableId: "#gridTable",
            successMessage: "发送成功",
            successTitle: '提示',
            //failMessage: '更新失败',
            failTitle: '提示'
        });
    }


    /**
     *-------------------------重新开始督查任务-----------------------
     */
    function Restartedit() {
        console.log("更新操作")
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("rebuildjob"),
            tableId: "#gridTable",
            successMessage: "操作成功",
            successTitle: '操作对话框',
            //failMessage: '更新失败',
            failTitle: '消息对话框'
        });
    }


    //显示编辑对话框
    function showView() {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "更新对话框",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    }

    /*
        $("#exportSummary").click(function () {
            // exportData=decodeURIComponent(exportData,true);//解码
            var url = "/export/ExportSummary" + '?' + exportData;
            console.log(exportData);
            window.open(url);

        });*/

    //删除
    $("#delete").click(function () {
        showDeleteView();
    });

    //显示删除对话框
    function showDeleteView() {
        showDeleteDialog({
            url: getUrl("delete"),
            tableId: "#gridTable",
            confirmTitle: "确认对话框",
            confirmMessage: "是否确定删除?",
            confirmOk: "确定",
            confirmCancel: "取消",
            successMessage: "删除成功",
            successTitle: "消息对话框",
            failMessage: "删除失败",
            failTitle: "消息对话框",
            errorTitle: "警告提示框",
            errorMessage: "您当前尚未选中一行，请选择后再试",
            errorOk: "确定"
        });
    }

    //保存数据
    function create() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("create"),
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            //failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }

    /**
     * 双击显示
     */
    $("#gridTable").dblclick(function (e) {
        showView();
    });
    //流程图表js
    $(function () {
        $(".nav>li:nth-child(10)").addClass("active");
    })
</script>

</body>
</html>